package 基础语法;

import java.util.ArrayList;
import java.util.Iterator;

public class 迭代器 {
    public static void main(String[] args) {
        ArrayList<Integer> a = new ArrayList<>();
        a.add(1);
        a.add(2);
        a.add(3);
        Iterator<Integer> iterator = a.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());

        }
        iterator = a.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());

        }

    }

}
